package com.bianmaba.example.controller;

import com.bianmaba.example.bean.User;
import com.bianmaba.example.respoistory.UserRespoistory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserRespoistory respoistory;

    @RequestMapping("add")
    public User add(@RequestBody User user) {
        return respoistory.save(user);
    }

    @RequestMapping("query")
    public List<User> add(String name) {
        return respoistory.findByName(name);
    }
}
